<!DOCTYPE html>

  <meta charset="UTF-8">

  <title>CSS Color Test: system color highlights values versus getSelection().addRange(targetRange)</title>

  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
  <link rel="help" href="https://www.w3.org/TR/css-color-4/#css-system-colors">
  <link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-styling">
  <link rel="match" href="reference/system-color-hightlights-vs-getSelection-001-ref.html">

  <!--

  Created: March 29th 2023

  Last modified: July 12th 2023

  Chromium bug report 932343 comment #c20: Issue 932343: Support text decoration properties in ::selection
  https://bugs.chromium.org/p/chromium/issues/detail?id=932343#c20

  Chromium bug report 1429019: Issue 1429019: [CSS4 Color] [CSS4 Pseudo] getSelection() color and background color should match system color highlights
  https://bugs.chromium.org/p/chromium/issues/detail?id=1429019

  WebKit Bug report 254691: [CSS4 Color] [CSS4 Pseudo] getSelection() color and background color should match system color highlights
  https://bugs.webkit.org/show_bug.cgi?id=254691

  -->

  <meta content="" name="flags">
  <meta content="This test checks that color and background color generated by window.getSelection().addRange(targetRange) correspond to system color highlights values." name="assert">

  <style>
  div
    {
      font-size: 40px;
      line-height: 1;
    }

  /*
     https://www.w3.org/TR/css-pseudo-4/#highlight-bounds
     For text, the corresponding overlay must cover at least
     the entire em box and may extend further above/below the
     em box to the line box edges.
  */

  span.system-color-highlight
    {
      background-color: Highlight;
      color: HighlightText;
    }

  /*

  Highlight
      Background of item(s) selected in a control.
  https://www.w3.org/TR/css-color-4/#valdef-system-color-highlight

  HighlightText
      Text of item(s) selected in a control.
  https://www.w3.org/TR/css-color-4/#valdef-system-color-highlighttext

  CSS4 Color Module
  5.2 System Colors
  https://www.w3.org/TR/css-color-4/#css-system-colors

  */
  </style>

  <script type="text/javascript">
  function startTest()
  {
  /* We first create an empty range */
  var targetRange = document.createRange();

  /* Then we select the node */
  targetRange.selectNode(document.getElementById("getSelection"));

  /* Finally, we now select such range of content */
  window.getSelection().addRange(targetRange);
  }

  </script>

  <body onload="startTest();">

    <div><span class="system-color-highlight">With system-color-highlight</span></div>

    <div>
      <span id="getSelection">With getSelection()</span>
    </div>
